package com.yloveg.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yloveg.dao.VPayOrderMapper;
import com.yloveg.entity.ShopOrders;
import com.yloveg.entity.VPayOrder;
import com.yloveg.service.VPayOrderService;


@Service
public class VPayOrderServiceImpl implements VPayOrderService {
 
    @Autowired
    private VPayOrderMapper vPayOrderMapper;

	@Override
	public VPayOrder selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return vPayOrderMapper.selectByPrimaryKey(id);
	}

	@Override
	public int insert(VPayOrder record) {
		// TODO Auto-generated method stub
		record.setCreateTime(new Date());
		record.setSts("Y");
		return vPayOrderMapper.insert(record);
	}

	@Override
	public int updateByPrimaryKeySelective(VPayOrder record) {
		// TODO Auto-generated method stub
		return vPayOrderMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public VPayOrder findOrderByOrderNo(String orderNo) {
		// TODO Auto-generated method stub
		
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("orderNo", orderNo);
		List<VPayOrder> orderList = vPayOrderMapper.selectByMap(map);
		if(orderList.size()!=1) {
			return null;
		}else {
			return orderList.get(0);
		}
		
	}

	@Override
	public PageInfo<VPayOrder> queryOrdersPage(int page, int limit, VPayOrder record) {
		PageHelper.startPage(page, limit);
		List<VPayOrder> VPayOrderList = vPayOrderMapper.queryVPayOrder(record);
		PageInfo<VPayOrder> resultPage=new PageInfo<VPayOrder>(VPayOrderList);
		return resultPage;
	}

	@Override
	public int selectByTodaySum(VPayOrder record) {
		
		return vPayOrderMapper.selectByTodaySum(record);
	}

	@Override
	public int selectSum(VPayOrder record) {
		
		return vPayOrderMapper.selectSum(record);
	}



}
